//
//  MyInfo.m
//  RSW.IOS
//
//  Created by zhaiqiuqiu on 16/10/23.
//  Copyright © 2016年 com.rs. All rights reserved.
//

#import "MyInfo.h"

@implementation MyInfo

@synthesize positionJob;
@synthesize headImagePath = _headImagePath;
@synthesize context;
@synthesize headImageURL = _headImageURL;

- (id)copyWithZone:(NSZone *)zone
{
    MyInfo *myInfo = [[self class] allocWithZone:zone];
    myInfo.userNumber = [self.userNumber copy];
    myInfo.userName = [self.userName copy];
    myInfo.loginName = [self.loginName copy];
    myInfo.qq = [self.qq copy];
    myInfo.mobilePhone = [self.mobilePhone copy];
    myInfo.logoURL = [self.logoURL copy];
    myInfo.departmentName = [self.departmentName copy];
    myInfo.departmentId = [self.departmentId copy];
    myInfo.tel = [self.tel copy];
    myInfo.email = [self.email copy];
    myInfo.positionJob = [self.email copy];
    
    return myInfo;
}

-(NSString*)headImagePath
{
    if(_headImagePath.length <=0 )
        return @"";
    
    if([_headImagePath rangeOfString:ServiceDefaultHeadImageTag].location != NSNotFound)
        return @"";
    
    return _headImagePath;
}

-(NSString*)headImageURL
{
    if(_logoURL.length <= 0 )
        return @"";
    
    if([_logoURL rangeOfString:ServiceDefaultHeadImageTag].location != NSNotFound)
        return @"";
    
    NSString *extension = [_logoURL pathExtension];
    if(extension.length <= 0)
        return @"";
    
    return _logoURL;
}

-(UIImage*)defaultHeadImage
{
    if([_logoURL rangeOfString:ServiceDefaultHeadImageTag].location != NSNotFound)
        return [UIImage imageNamed:[_logoURL substringFromIndex:[_logoURL rangeOfString:ServiceDefaultHeadImageTag].length]];
    return [UIImage imageNamed:@"img_defaulthead.png"];
}

-(XLGContext*)context
{
    return [XLGContext context];
}

-(EntAddressBookContact*)entAddressBookContact
{
    EntAddressBookContact *c = [EntAddressBookContact new];
    c.userName = self.userName;
    c.userNumber = self.userNumber;
    c.logoURL = self.logoURL;
    return c;
}

+(MyInfo*)myInfo
{
    return (MyInfo*)[CCurrentUser currentUser];
}

@end
